1 using System.Collections;
2 using
System.Collections.Generic;
3 using
UnityEngine;
4
5 public
class MonsterPatrol : MonoBehaviour {
6
7     
public float speed;
8
9     Rigidbody2D rb;
10
11     
// Use this for initialization
12     
void Start () {
13         rb = GetComponent<Rigidbody2D>();
14     }
15     
16     
// Update is called once per frame
17     
void Update () {
18         Move();
19     }
20
21     
void Move()
22     {
23         Vector2 temp = rb.velocity;
24
25         temp.x = speed;
26         rb.velocity = temp;
27     }
28 }


Use this for initialization

Update is called once per frame




Trò chơi bắn đạn đơn giản sử dụng Unity 13.471 lượt xem

Gõ tìm kiếm nhanh...